package com.atguigu.tingshu.account;

import com.atguigu.tingshu.account.impl.AccountDegradeFeignClient;
import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.model.account.RechargeInfo;
import com.atguigu.tingshu.vo.account.AccountDeductVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * <p>
 * 账号模块远程调用API接口
 * </p>
 *
 * @author atguigu
 */
@FeignClient(
        value = "service-account",
        contextId = "accountFeignClient",
        fallback = AccountDegradeFeignClient.class,
        path = "api/account"
)
public interface AccountFeignClient {

    /**
     * 检查及扣减账户余额
     *
     * @param accountDeductVo 账户扣除参数
     */
    @PostMapping("/userAccount/checkAndDeduct")
    Result<Void> checkAndDeduct(@RequestBody AccountDeductVo accountDeductVo);

    /**
     * 根据订单号获取充值信息
     *
     * @param orderNo 订单号
     * @return 订单充值信息
     */
    @GetMapping("/rechargeInfo/getRechargeInfo/{orderNo}")
    Result<RechargeInfo> getRechargeInfo(@PathVariable String orderNo);

    /**
     * 在支付成功后更新账户
     *
     * @param orderNo 订单号
     */
    @GetMapping("/userAccount/updateAccountOnPaySuccess/{orderNo}")
    Result<Void> updateAccountOnPaySuccess(@PathVariable String orderNo);
}
